// -----------------------------------------------------------------------
//  <copyright file="GetRolePageQuery.cs" company="LiuliuSoft">
//      Copyright (c) 2022-2024 DaprPlus. All rights reserved.
//  </copyright>
//  <site>https://dapr.plus</site>
//  <last-editor>郭明锋</last-editor>
//  <last-date>2024/12/9 11:01:27</last-date>
// -----------------------------------------------------------------------

using DaprPlus.Identity.Domain.Entities;


namespace DaprPlus.Identity.Application.Identity.Roles.Queries;

[AuthConfig(typeof(Role), ResourceAccessType.RoleLimit, "GetPage")]
public class GetRolePageQuery : PageQuery<PageResult<RoleOutDto>>
{ }

public class GetRolePageQueryHandler(IQueryRepository<Role> queryRepository)
    : IRequestHandler<GetRolePageQuery, PageResult<RoleOutDto>>
{
    public async Task<PageResult<RoleOutDto>> Handle(GetRolePageQuery request, CancellationToken cancellationToken)
    {
        var spec = new PageQuerySpecification<Role>(request.PageCondition, request.FilterGroup);
        var page = await queryRepository.GetPageAsync<RoleOutDto>(spec, cancellationToken);
        return page;
    }
}

